package com.atguigu.algorithm;

import java.util.HashSet;
import java.util.Set;

public class TheShortestDigest {
    public static String findTheSubString(String[] words,String[] keys){
        int max=0;
        StringBuilder sb=null;
        for(int i=0;i<words.length;i++){
            int tmp=0;
            Set<String> set=new HashSet<>();
            sb=new StringBuilder();
            //初始化完成
            for(int j=0;j<keys.length;j++){
                set.add(keys[j]);
            }
            sb.append(words[i]);
            tmp++;
            if(set.contains(words[i])){
                set.remove(words[i]);
            }
            if(set.isEmpty()){
                if(tmp>max){
                    max=tmp;
                }
                continue;
            }
        }
        return sb.toString();
    }
}
